<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
6

<script>
    window.οnbefοreunlοad = function (event) {
        alert("===onbeforeunload===");
        if (event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey) {
            alert("你关闭了浏览器");
        } else {
            alert("你正在刷新页面");
        }
    }
</script>

</body>
</html>